<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript"
	src="static/jquery-easyui-1.5.5.3/jquery.min.js"></script>
<link rel="stylesheet"
	href="webjars/bootstrap/3.3.7-1/css/bootstrap.css">
<link rel="stylesheet"
	href="static/jquery-easyui-1.5.5.3/themes/material-teal/easyui.css" />
<link rel="stylesheet"
	href="static/jquery-easyui-1.5.5.3/themes/icon.css" />
<script type="text/javascript"
	src="static/jquery-easyui-1.5.5.3/jquery.easyui.min.js"></script>
<script type="text/javascript"
	src="static/jquery-easyui-1.5.5.3/locale/easyui-lang-zh_CN.js"></script>
<script type="text/javascript"
	src="webjars/bootstrap/3.3.7-1/js/bootstrap.js"></script>
<script type="text/javascript">
	function pwd(oldPwd) {
		$.post('password', {
			password : oldPwd
		}, function(data) {
			if (data) {
				$("#oldPwd_error").html("");
			} else {
				$("#oldPwd_error").html("原密码输入错误");
			}
		});
	}
	$(function() {
		$('#mybtn').click(function() {
			var oldPwd = $('#oldPwd').val();
			var newPwd = $('#newPwd').val();
			var confirmPwd = $('#confirmPwd').val();
			
			if (oldPwd == "" || oldPwd == null) {
				$('#oldPwd_error').html("请输入原密码");
			} else if (newPwd == "" || newPwd == null) {
				$('#newPwd_error').html("请输入密码");
			} else if (confirmPwd == "" || confirmPwd == null) {
				$('#newPwd_error').html("");
				$('#confirmPwd_error').html("请输入密码");
			} else if (newPwd != confirmPwd) {
				$('#newPwd_error').html("");
				$('#confirmPwd_error').html("两次密码不一致");
			} else {
				alert("修改成功,请重新登陆！");
				window.parent.location = "change?newPwd=" + newPwd;
			}
		});
	});
</script>
<style type="text/css">
	.row{
		/* margin:20px; */
		/* margin:auto; */
		/* border: 1px solid black; */
		width: 500px;
		height: auto;
		
	}
	.form-group{
		padding: 20px;
	}
</style>
</head>
<body>
	<div class="row">
		<form action="post">
			<div class="form-group">
				<label class="col-md-4" style="text-align: right;">请输入原密码：</label>
				<div class="col-md-8">
					<input class="form-control"placeholder="请输入原密码" type="password" id="oldPwd" onchange="pwd(this.value)">
				</div>
			</div>
			<div class="col-md-12" style="text-align: center;"><span id="oldPwd_error" style="color: red;"></span></div>
			
			<div class="form-group">
				<label class="col-md-4" style="text-align: right;">请输入新密码：</label>
				<div class="col-md-8">
					<input class="form-control"placeholder="情输入新密码" type="password" id="newPwd">
				</div>
			</div>
			<div class="col-md-12" style="text-align: center;"><span id="newPwd_error"style="color: red;"></span></div>
			
			<div class="form-group">
				<label class="col-md-4" style="text-align: right;">确认密码：</label>
				<div class="col-md-8">
					<input  class="form-control"placeholder="确认密码" type="password" id="confirmPwd">
				</div>
			</div>
			<div class="col-md-12" style="text-align: center;"><span id="confirmPwd_error" style="color: red;"></span></div>
			<div class="form-group">
				<div class="col-md-4"></div>
				<div class="col-md-8">
					<button type="button" style="width: 275px;" class="btn btn-info" id="mybtn">提交</button>
				</div>
			</div>
		</form>
	</div>
</body>
</html>